#ifndef CURSOR_HPP
#define CURSOR_HPP

#include <vector>
#include <string>
#include <functional>

#include "clang-c/Index.h"

class Cursor;

class CursorType {
public:
    CursorType(const CXType &type);

    std::string display_name() const;

    int argument_count() const;

    CursorType argument(unsigned index) const;

    CursorType canonical_type() const;

    Cursor declaration() const;

    CXTypeKind kind() const;

    bool is_const() const;
private:
    CXType handle_;
};


class Cursor {
public:
    using List = std::vector<Cursor>;
    using Visitor = CXCursorVisitor;
    using Filter = std::function<bool(Cursor)>;

    Cursor(CXCursor cursor);
    CXCursorKind kind() const;
    std::string spelling() const;
    std::string display_name() const;
    std::string source_file() const;
    std::string file_line() const;
    bool is_definition() const;

    CursorType type() const;

    List children(Filter filter = {}) const;

    void visit_children(Visitor vis, void *data = nullptr);

private:
    CXCursor handle_;
};

#endif // CURSOR_HPP
